<template>
	<view class="box">
		<view style="padding-top: 30vh;" v-if="!resObj.troubleId">
			<u-empty mode="list"></u-empty>
		</view>
		<view class="plr20 pt20 pb240" v-if="resObj.troubleId">
			<view class="boxItem mb20">
				<view class="tc mb30">基本信息</view>
				<view class="flex mb20">
					<view class="name w160">隐患简题：</view>
					<view class="value">{{resObj.troubleTitle}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患编号：</view>
					<view class="value">{{resObj.troubleNum}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患所在单位：</view>
					<view class="value">{{resObj.troubleUnit}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患等级：</view>
					<view class="value">{{resObj.zdGrade}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患类型：</view>
					<view class="value">{{resObj.specialtyAssort}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患来源：</view>
					<view class="value">{{resObj.troubleSource}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">填报人：</view>
					<view class="value">{{resObj.createUser}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">填报人所属单位：</view>
					<view class="value">{{resObj.createOrg}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">发现人：</view>
					<view class="value">{{resObj.findPeople}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">发现人所属单位：</view>
					<view class="value">{{resObj.findPeopleUnit}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">填报时间：</view>
					<view class="value">{{resObj.createDate.slice(0,11)}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">发现日期：</view>
					<view class="value">{{resObj.findDate.slice(0,11)}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">隐患内容：</view>
					<view class="value">{{resObj.troubleContent}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">归属职能部门：</view>
					<view class="value">{{resObj.attachFunctDept}}</view>
				</view>
				<view class="flex mb20">
					<view class="name w160">相关附件：</view>
					<view class="cob" @click="checkAttac('080106')">查看</view>
				</view>
			</view>
		</view>
		<view class="maintenance">
			<view>
				<image src="../../static/iconAuditInformation.png" @click="navTo('auditOpinion')"></image>
				<view>审核信息</view>
			</view>
			<view>
				<image src="../../static/iconTransferInformation.png" @click="navTo('transferInformation')"></image>
				<view>流转信息</view>
			</view>
			<view>
				<image src="../../static/iconSave.png" @click="navTo('modifyHiddenDanger')"></image>
				<view>编辑</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				resObj: {},
				resObj1:{},//用于传递的数据
				dictList: [],
				params:{
					troubleId:''
				}
			}
		},
		onLoad(e) {
			if (e.hiddenDangerId) {
				this.params.troubleId = e.hiddenDangerId
				console.log(this.params.troubleId)
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			toJSON () {},
			init(){
				this.request(this.$api.selectDataById, this.params, "POST").then((res) => {
					this.resObj = res.resultValue.items[0]
					this.resObj1 = {...res.resultValue.items[0]}
					this.dictList = res.resultValue.dicts
					this.dictsFn()
				})
			},
			dictsFn(){
				let obj = {
					zdGrade:this.resObj.zdGrade,
					specialtyAssort:this.resObj.specialtyAssort,
					troubleSource:this.resObj.troubleSource,
					attachFunctDept:this.resObj.attachFunctDept,
				}
				let arr = []
				for(let k in obj){
					this.dictList.forEach(item=>{
						if(k == item.name){
							item.values.forEach(i=>{
								if(obj[k] == i.value){
									arr.push({
										name:k,
										value:i.text
									})
								}
							})
						}
					})
				}
				console.log(arr)
				arr.forEach((item)=>{
					if(item.name=="specialtyAssort"){
						this.resObj.specialtyAssort = item.value
					}else if(item.name=="troubleSource"){
						this.resObj.troubleSource = item.value
					}else if(item.name=="attachFunctDept"){
						this.resObj.attachFunctDept = item.value
					}else if(item.name=="zdGrade"){
						this.resObj.zdGrade = item.value
					}
				})
			},
			navTo(e) {
				uni.navigateTo({
					url: './' + e + '?item='+ JSON.stringify(this.resObj1)+'&dictList='+JSON.stringify(this.dictList)
				})
			},
			checkAttac(classify) {
				console.log(classify + '\n' + this.resObj.troubleId)
				uni.navigateTo({
					url: './../checkTheAttachment/checkTheAttachment?classify=' + classify + '&connectId=' + this
						.resObj.troubleId
				})
			}
		}
	}
</script>

<style scoped>
	.box {
		min-height: 100vh;
		background-color: #F1F2F5;
	}

	.maintenance {
		background-color: #FFFFFF;
		position: fixed;
		bottom: 0;
		height: 228rpx;
		width: 100%;
		box-shadow: 0 -1px 11px 0 rgba(0, 0, 0, 0.09);
		text-align: center;
		padding: 40rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-around;
	}

	.maintenance image {
		width: 84rpx;
		height: 84rpx;
	}

	.maintenance view {
		font-family: PingFangSC-Regular;
		font-weight: Regular;
		font-size: 28rpx;
		color: #65717D;
	}

	.boxItem {
		padding: 30rpx;
		background-color: #fff;
		box-shadow: 0 2px 4px 0 rgba(237, 237, 237, 0.50);
		border-radius: 16rpx;
		position: relative;
	}

	.name {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #89939E;
		padding-right: 20rpx;
	}

	.value {
		flex: 1;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
	}

	.cob {
		flex: 1;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #3473F9;
	}
</style>
